<?php
class blog_view extends SClass {

    public function process() {
        $user = $this->getUserSecure();
        if ($user) {
            if ($user->getLevel() >= 1) {
        	   $this->assign('autorized', 1);
            }
        }
        $post = ServiceUtils::GetFactory()->getBlogService()->getPostsAll();
        $a = array();
        while ($x = $post->getNext()) {
            $a[] = array(
                'id' => $x->getId(),
                'title' => $x->getTitle(),
                'preview' => $x->getPreview(),
                'postdate' => $x->getPostdate(),
                'url' => Engine_LinkMaker::GetURLByContentID('blog_post_view',
                    $x->getId()),
                'urledit' => Engine_LinkMaker::GetURLByContentID('blog_post_edit',
                    $x->getId()),
                'urldelete' => Engine_LinkMaker::GetURLByContentID('blog_post_delete',
                    $x->getId()),
                'user' => ServiceUtils::GetFactory()->getUserService()->getUserByID(
                    $x->getUserid())->getName()
            );
        }
        $this->assign('postArray', $a);
    }

}